#ifndef JSDL_H
#define JSDL_H

#include "jvideoview.h"
struct SDL_Window;
struct SDL_Renderer;
struct SDL_Texture;
class JSDL : public JVideoView
{
public:
    JSDL();
    /////////////////////////////////////////////////
    /// \brief Init 初始化渲染窗口
    /// \param w    窗口宽度
    /// \param h    窗口高度
    /// \param fmt  绘制的像素格式
    /// \param win_id 窗口句柄，如果为空就创建新窗口
    /// \return
    ///
    virtual bool Init(int w,int h,Format fmt=RGBA) override;

    ///////////////////////////////////////////////////
    /// \brief Draw      渲染图像
    /// \param data      渲染的二进制数据
    /// \param linesize   一行数据的字节数，对于yuv420p就是一行y的字节数
    /// \return
    ///
    virtual bool Draw(const unsigned char* data,int linesize=0) override;
    virtual bool Draw(const unsigned char* y,int y_pitch,
                      const unsigned char* u,int u_pitch,
                      const unsigned char* v,int v_pitch) override;


    bool isExit() override;
    virtual void Close() override;

private:
    SDL_Window* win_ = nullptr;
    SDL_Renderer* render_ = nullptr;
    SDL_Texture* texture_ = nullptr;
};

#endif // JSDL_H
